package com.zhiwang.planet.mvvm.viewmodel.main

import android.view.View
import android.view.ViewGroup
import androidx.databinding.ObservableField
import com.zhiwang.planet.widget.ExpandableTextView

data class MessageItemViewModel constructor(var id: String,
                                            var type: String,
                                            var content: String,
                                            var hasRead: ObservableField<Boolean> = ObservableField(false),
                                            var diamondReward: String,
                                            var beanReward: String) : SetReadCallBack {
    override fun onCallBack() {
        hasRead.set(true)
    }

    var expand: Boolean = false

    fun toggle(v: View) {
//        ((v as ViewGroup).getChildAt(0) as ExpandableTextView).toggle(true)
//        expand = !expand

        if (hasRead.get() != true) {
            ConnectionViewModel.message.value = ConnectionProto(type, id,this)
        }
    }
}